package com.igoal.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "school")
public class School implements Serializable, Audit {

	private static final long serialVersionUID = -677777077436976814L;
	private Long id;
	private String name;
	private City city;
	private String mainStudy;
	private String title;
	private Date createDate;
	private Date updateDate;
	private DataStatus status;
	private Set<UserSchool> userSchools = new HashSet<UserSchool>(0);

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "city_id")
	public City getCity() {
		return city;
	}

	public void setCity(City city) {
		this.city = city;
	}
	
	@Column(name = "main_study", nullable = true)
	public String getMainStudy() {
		return mainStudy;
	}

	public void setMainStudy(String mainStudy) {
		this.mainStudy = mainStudy;
	}
	
	@Column(name = "title", nullable = true)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "cdate", nullable = false, length = 19)
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date date) {
		this.createDate = date;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false, name = "mdate")
	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date date) {
		this.updateDate = date;
	}

	@Enumerated(EnumType.STRING)
	@Column(name = "status", nullable = false, length = 50)
	public DataStatus getStatus() {
		return this.status;
	}

	public void setStatus(DataStatus status) {
		this.status = status;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.school")
	public Set<UserSchool> getUserSchools() {
		return this.userSchools;
	}

	public void setUserSchools(Set<UserSchool> userSchools) {
		this.userSchools = userSchools;
	}

}
